<!-- 用户地址管理 -->
<template>
  <page-header-wrapper>
    <a-card class="table-card">
      <GzSearchForm :searchFunc="searchFunc" :resetFunc="() => { searchData = {} }" searchConditionNum="6">
        <GzTextUp v-model:value="searchData['fansId']" placeholder="客户ID" />
        <GzTextUp v-model:value="searchData['cstmNo']" placeholder="信息局唯一标识" />
        <GzTextUp v-model:value="searchData['agentNo']" placeholder="区县归属机构号" />
        <a-form-item class="table-search-item" style="width: 350px;">
          <a-range-picker v-model:value="searchData['startEndTime']" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD" />
        </a-form-item>
      </GzSearchForm>
      <!-- 列表渲染 -->
      <GzTable
        ref="infoTableRef"
        :init-data="true"
        :req-table-data-func="reqTableDataFunc"
        :table-columns="tableColumns"
        :search-data="searchData"
      >
        <template #topBtnSlot>
          <a-button v-if="$access('ENT_DATA_REPORT_REAL_NAME_INFO_EXPT')" type="primary" @click="exportDataReports">
            <template #icon>
              <ArrowUpOutlined />
            </template>
            导出
          </a-button>
        </template>
        <template #bodyCell="{ column, record }">
          <!-- <template v-if="column.key === 'mchNo'">
            <span>{{ record.isDeleted ==0 ? record.mchNo : '--' }}</span>
          </template>
          <template v-if="column.key === 'sex'">
            <span v-if="record.sex == 0">未知</span>
            <span v-if="record.sex == 1">男</span>
            <span v-if="record.sex == 2">女</span>
          </template>
          <template v-if="column.key === 'mchName'">
            <span>{{ record.mchName ? record.mchName : '--' }}</span>
          </template> -->
        </template>
      </GzTable>
    </a-card>
  </page-header-wrapper>
</template>
  
  <script lang="ts" setup>
  import {$apiRealNameList,$apiRealNameExportRealAward} from '@/api/dataReports/realNameTable/index'
  import { ref, reactive,getCurrentInstance } from 'vue'
  const { $infoBox, $access } = getCurrentInstance()!.appContext.config.globalProperties
  const infoTableRef = ref()
  const vdata = reactive({
    startEndTime:null
  })
  
  let tableColumns = reactive([
    { key: 'fansId', title: '客户ID', dataIndex: 'fansId', fixed: 'left' },
    { key: 'cstmNo', title: '信息局唯一标识', dataIndex: 'cstmNo' },
    { key: 'createdAt', title: '实名时间', dataIndex: 'createdAt' },
    { key: 'agentNo', title: '区县归属机构号', dataIndex: 'agentNo' },
  ])
  const searchData: any = ref({})
  // 请求table接口数据
  function reqTableDataFunc(params: any) {
  
    params.startTime = searchData.value.startEndTime ? searchData.value.startEndTime[0] : ''
    params.endTime = searchData.value.startEndTime ? searchData.value.startEndTime[1] : ''
    return $apiRealNameList({ ...params,})
  }

  const exportDataReports = () =>{
    $apiRealNameExportRealAward({...searchData.value,startTime:searchData.value?.startEndTime ?searchData.value?.startEndTime[0]:'' ,endTime:searchData.value?.startEndTime?searchData.value?.startEndTime[1]:''}).then(res=>{
      $infoBox.message.success('导出成功')
    })
  }

  // 搜索
  function searchFunc() {
    infoTableRef.value.refTable(true)
  }
  </script>